package com.bytedance.retrofit2;

import com.bytedance.retrofit2.client.SsResponse;

public final class ResponseWrapper<T> {
    public final SsResponse rawResponse;
    public final T body;

    ResponseWrapper(SsResponse rawResponse, T t) {
        this.rawResponse = rawResponse;
        this.body = t;
    }

    public static <T> ResponseWrapper<T> createResponseWrapper(T t, SsResponse rawResponse) {
        if (rawResponse == null) {
            throw new NullPointerException("rawResponse == null");
        } else if (rawResponse.success()) {
            return new ResponseWrapper(rawResponse, t);
        } else {
            throw new IllegalArgumentException("rawResponse must be successful response");
        }
    }
}